/**
 * Created by JetBrains RubyMine.
 * User: mutouyihao
 * Date: 12-4-26
 * Time: 下午3:11
 * 提单的效果，页面显示隐藏等效果
 *
 * 查询提单后，提单的交互操作
*/

$(document).ready(
    function(){
        //集装箱提示框
        $(".box-row-map-view").live("mouseover", null, function () {
            var $win = $("#boxDetailWin"), $row = $(this);
            $win.show();
            $row.addClass("ctn-h");
            $("#boxDetailWin").css("top", $(this).offset().top - $("#map").offset().top - 45);
            $("ctn_type,seal_no,vehicle_no".split(",")).each(function (index, name) {
                $win.find("." + name).text($row.find("." + name).attr("value"));
            });
            $win.find(".ctn-location").html($row.find(".ctn-location").html());
        });

        $(".box-row-map-view").live("mouseout", null, function () {
            $("#boxDetailWin").hide();
            $(this).removeClass("ctn-h");
        });
        //鼠标移动到提示框上不消失
        var will_hide;
        $(".box-row-map-view").live("mouseenter", null, function () {
            if(will_hide){
                clearTimeout(will_hide);
            }
        });
        $(".box-row-map-view").live("mouseleave", null, function () {
            $("#boxDetailWin").show();
            will_hide = setTimeout("$('#boxDetailWin').hide()", 500);
        });
        $("#boxDetailWin").hover(function () {
            if (will_hide) {
                clearTimeout(will_hide);
                $("#boxDetailWin").show();
            }
        }, function () {
            $("#boxDetailWin").hide();
        });

    }
);

//显示集装箱类表tab页，隐藏历史
function hide_ctn_history_view_bl(){
    $("#bl_content_wrap").show();
    $("#history_win").hide();
    $("#bl_tab").addClass('selected');
    $("#ctn_his_tab").removeClass( 'selected');
}
//显示历史tab页
function show_ctn_history_hide_bl(ctnNo){
    $("#history_win").show();
    $("#bl_content_wrap").hide();
    $("#bl_tab").removeClass( 'selected');
    $("#ctn_his_tab").addClass( 'selected');
    $("#ctn_his_tab").show();
    if(ctnNo != undefined)
        $("#ctn_his_tab").html(ctnNo+"历史");
}

function close_win(win_name) {
    $("#" + win_name).hide();
}

function toggle_bl_containers( bl_no){

    var img = $("#toggle_bl_" + bl_no + " img");
    if (img.attr("src") == "/assets/down-fh.png") {
        img.attr({src:"/assets/up-fh.png", title:"收起"});
        $("#bill_detail_of_" + bl_no).slideDown("fast");
    } else {
        img.attr({src:"/assets/down-fh.png", title:"展开"});
        $("#bill_detail_of_" + bl_no).slideUp("fast");
    }
    $("[id*='toggle_bl_'] img").not("#toggle_bl_" + bl_no + " img").attr({src:"/assets/down-fh.png", title:"展开"});
    $("[id*='bill_detail_of_']").not("#bill_detail_of_" + bl_no).hide("fast");
}



